package com.hxgis.oc.product.base;

import lombok.Getter;
import lombok.Setter;

import java.io.File;
import java.util.function.Function;

@Getter
@Setter
public abstract class ProduceTask<E extends Comparable<? super E>> implements Runnable, Comparable<ProduceTask<E>> {
    protected Long fileID;
    protected String productType;
    protected String dataSet;
    protected File outputFile;
    protected Function<ProduceTask, Boolean> checker;

    public ProduceTask(Long fid,String ds)
    {
        fileID = fid;
        dataSet = ds;
    }

    public abstract boolean producing();

    @Override
    public int compareTo(ProduceTask<E> other) {
        return (int)(other.fileID - fileID);
    }

    @Override
    public void run() {
        if(producing()){
            ProductFactoryManager.publish(this);
        }
    }
}
